#! /usr/bin/env python
# -*- coding:utf-8 -*-
# Author Jmz


# monkey.patch_all() 打补丁， 使之 能过
# 在使用协程时 一定要打一个gevent 的补丁， 如果不用的话，那么就 无法遇 I/0阻塞切换

from gevent import monkey,spawn,joinall;monkey.patch_all()
import time

def test(name,age):
    print('%s 1'%name)
    time.sleep(1)
    print('%d 2'%age)
    time.sleep(2)
    print('3')
    time.sleep(4)
    print('4')

start_time= time.time()
g1 = spawn(test,'jmz',23)
g2 = spawn(test,'jly',25)
g3 = spawn(test,'qqx',24)
g4 = spawn(test,'aa',11)
joinall([g1,g2,g3,g4])
end_time = time.time()
print(end_time-start_time)
